//
//  BaseTabBarController.m
//  Lottery
//
//  Created by lxc on 2017/7/15.
//  Copyright © 2017年 cp. All rights reserved.
//

#import "BaseTabBarController.h"

@interface BaseTabBarController ()

@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 电梯知识
    UIStoryboard *storyboard1 = [UIStoryboard storyboardWithName:@"LotteryKnowledge" bundle:nil];
    UINavigationController *nvc1 = [storyboard1 instantiateInitialViewController];
    
    NSString *elevatorConditionStoryboardName = @"LotterySituation";
    
    // 电梯状况
    UIStoryboard *storyboard2 = [UIStoryboard storyboardWithName:elevatorConditionStoryboardName bundle:nil];
    UINavigationController *nvc2 = [storyboard2 instantiateInitialViewController];
    [self setViewControllers:@[nvc1,nvc2]];
    
    
    UIEdgeInsets imageEdgeInsets = UIEdgeInsetsMake(-2, 0, 2, 0);
    
    // self.delegate = self;
    
    for (NSInteger i  = 0; i < self.tabBar.items.count; i++)
    {
        UITabBarItem *item = [self.tabBar.items objectAtIndex:i];
        
        NSString *itemTitle = [self tabbarTitles][i];
        
        NSString *normalImageName = [self normalImagesArray][i];
        
        NSString *selecteImageName = [self selectedImagesArray][i];
        
        item.selectedImage = [[UIImage imageNamed:selecteImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        
        item.image = [[UIImage imageNamed:normalImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [item setTitle:itemTitle];
        
        item.titlePositionAdjustment = UIOffsetMake(0, -5);
        item.imageInsets = imageEdgeInsets;
    }
    
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:kSetCOLOR(0x333333), NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
    
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:kSetCOLOR(0x35517c), NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
    
}


#pragma mark - pravite

- (NSArray *)normalImagesArray
{
    NSArray *normalImagesArray =   @[@"tabbar_knowledge_nor",
                                     @"tabbar_situation_nor"];
    
    return normalImagesArray;
}

- (NSArray *)selectedImagesArray
{
    NSArray *selectedImagesArray = @[@"tabbar_knowledge_pressed",
                                     @"tabbar_situation_pressed"];
    
    return selectedImagesArray;
}

- (NSArray *)tabbarTitles
{
    NSArray *titleArray = @[@"彩票知识",@"开奖情况"];
    
    return titleArray;
}

@end
